from .cases_data import load_cases, get_case_names

def get_samples_info():
    all_cases = load_cases()
    samples_info = []
    for case in all_cases:
        samples_info.append({
            "案例名称": case.案例名称,
            "经营范围": case.经营范围,
            "分类代码": f"{case.正确分类['门类'].code}-{case.正确分类['大类'].code}-{case.正确分类['中类'].code}-{case.正确分类['小类'].code}",
            "分类名称": f"- 门类名称：{case.正确分类['门类'].name}\n- 大类名称：{case.正确分类['大类'].name}\n- 中类名称：{case.正确分类['中类'].name}\n- 小类名称：{case.正确分类['小类'].name}",
        })
    return "\n\n".join([f"{info['案例名称']}\n- {info['经营范围']} \n- 分类代码: {info['分类代码']} \n{info['分类名称']}" for info in samples_info])

def analyze_cases():
    # 获取全部案例数据
    all_cases = load_cases()
    
    # 示例分析：统计各门类分布
    category_dist = {}
    for case in all_cases:
        category = case.正确分类['门类'].code
        category_dist[category] = category_dist.get(category, 0) + 1
    
    print(f"行业门类分布: {category_dist}")

if __name__ == "__main__":
    info = get_samples_info()
    print(info)
